package xinxin.com.SimpleFactoryPattern;

import xinxin.com.SimpleFactoryPattern.Factory.OperationFactory;
import xinxin.com.SimpleFactoryPattern.Operation.Operation;

import java.util.Scanner;

public class SimpleFactoryPattern {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入第一个操作数");
        double numberA = sc.nextDouble();
        System.out.println("请输入第二个操作数");
        double numberB = sc.nextDouble();
        System.out.println("请输入操作符");
        String oper = sc.next();
        Operation operation = OperationFactory.createOperate(oper);
        operation.set_numberA(numberA);
        operation.set_numberB(numberB);
        double result = 0;
        try {
            result = operation.GetResult();
            System.out.println("结果为：" + result);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
